<template>
    <div class="teamplate-index">
        <div class="container-fluid ">
            <div class="row">
                <div class="col-lg-9 col-md-12 col-xs-12 file-p">
                    <div class="row h-msg clearfix">
                        <div class="user pull-left">
                            <div class="ico">
                                <img :src="cfg.assets+'/images/lsgl-m.png'" alt="">
                            </div>
                            <div class="text">
                                <p class="f666" style="margin-top:5px;">收款:<span> {{initialization.cashier.shky}}</span></p>
                            </div>
                        </div>
                        <div class="pull-left shu"></div>
                        <div class="pull-left">
                            <div class="form-group">
                                <label>销售：</label>
                                <select class="form-control" id="k_alt_y">
                                    <option v-for=" (item,index) in initialization.theSalesman" :value="item.xshyid">{{item.xshy}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="pull-left">
                            <div class="form-group">
                                <label>扣率(k)：</label>
                                <input type="text" class="form-control" :readonly='initialization.adminid' id="k_alt_k" v-model="zdkoul">
                            </div>
                        </div>
                        <div class="pull-left">
                            <div class="form-group">
                                <label>货位：</label>
                                <!-- <input type="text" class="form-control" :readonly='true' v-model="initialization.huowname"> -->
                                <select class="form-control" id="k_alt_z">
                                    <option v-for=" (item,index) in initialization.huowei" :value="item.hw">{{item.huowname}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="pull-left">
                            <div class="form-group">
                                <label>部门(m)：</label>
                                <select class="form-control" id="k_alt_m">
                                    <option v-for=" (item,index) in initialization.department" :value="item.hw">{{item.bm}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="pull-left shu"></div>
                        <div class="pull-left">
                            <i class="iconfont icon-shouyintai"></i>
                            {{initialization.cashier.sktid}}
                            <i class="iconfont icon-biaoqian-"></i>
                            {{initialization.fdbsMap.fdbs}}
                            <div class="vpn vpn-offline"></div>
                        </div>
                    </div>
                    <div class="b-main">
                        <div class="row t-input">
                            <div class="col-lg-9 col-md-8 col-sm-8">
                                <form class="form-horizontal">
                                    <div class="form-group">
                                        <div class="input-group col-sm-10 col-md-10 col-lg-10 md-search col-md-offset-2">
                                            <span class="input-group-btn">
                                                <button class="btn btn-default" :class="searchText=='搜索会员(F2)'?'on':''" type="button" @click="onSwitch" v-text="searchText"></button>
                                            </span>
                                            <input type="text" class="form-control" v-show="searchText=='搜索会员(F2)'" id="j_searchMember" v-model="changeValue.searchMsg" @input="onSearchMember" placeholder="请输入会员卡号、姓名、手机号、助记码或二维码">
                                            <input type="text" class="form-control" v-show="searchText=='搜索商品(F2)'" id="j_searchDrug" v-model="changeValue.searchMsg" @input="onSearchDrug" placeholder="请输入名称、条码、助记码、编码或零售价">
                                            <span class="iconfont icon-sousuo" v-show="searchText=='搜索商品(F2)'" @click="onAdorn1"></span>
                                            <span class="iconfont icon-sousuo" v-show="searchText=='搜索会员(F2)'" @click="onAdorn2"></span>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="col-lg-3 col-md-4 col-sm-4 right">
                                <div class="liushuihao">当前流水号：{{initialization.liushui}} </div>
                            </div>
                        </div>
                        <div class="row b-num">
                            <div class="col-sm-9">
                                <div class="top clearfix">
                                    <ul>
                                        <li class="form-inline">
                                            <span>数量(s)</span>
                                            <div class="form-group">
                                                <div class="input-group">
                                                    <input type="number" class="form-control" id="k_alt_s" v-on:focus="onQuantityFocus" v-on:blur="onQuantityBlur" v-model="drugDetails.list.shl">
                                                </div>
                                            </div>
                                            <span class="red">{{shlMsg}}</span>
                                        </li>
                                        <li class="form-inline">
                                            <span>单价(d)</span>
                                            <div class="form-group">
                                                <div class="input-group">
                                                    <input type="number" class="form-control" id="k_alt_d" v-on:focus="onPriceFocus" :readonly='initialization.adminid' v-on:blur="onPriceBlur"
                                                        v-model="drugDetails.list.dj">
                                                    <div class="input-group-addon">元</div>
                                                </div>
                                            </div>
                                            <span class="red">{{djMsg}}</span>
                                        </li>
                                        <li class="form-inline">
                                            <span>扣率(c)</span>
                                            <div class="form-group">
                                                <div class="input-group">
                                                    <input type="number" class="form-control" v-on:focus="onDiscountFocus" :readonly='initialization.adminid' v-on:blur="onDiscountBlur" v-model="drugDetails.list.koul" id="k_alt_c">
                                                    <div class="input-group-addon" id="j_botton">%</div>
                                                </div>
                                            </div>
                                            <span class="red">{{koulMsg}}</span>
                                        </li>
                                    </ul>
                                </div>
                                <ul class="list clearfix">
                                    <li class="col-lg-3 col-md-4 col-sm-4"><span class="f888">品名</span>{{drugDetails.list.spmch}}</li>
                                    <li class="col-lg-3 col-md-4 col-sm-4"><span class="f888 ">规格</span>{{drugDetails.list.shpgg}}</li>
                                    <li class="col-lg-3 col-md-4 col-sm-4 " id="chandi"><span class="f888 ">产地</span>{{drugDetails.list.shpchd}}</li>
                                    <li class="col-lg-3 col-md-4 col-sm-4"><span class="f888">零售价</span>{{drugDetails.list.lshj}}</li>
                                    <li class="col-lg-3 col-md-4 col-sm-4"><span class="f888">编号</span>{{drugDetails.list.spbh}}</li>
                                    <li class="col-lg-3 col-md-4 col-sm-4 red " id="pihao"><span>批号</span>{{drugDetails.list.pihao}}</li>
                                    <li class="col-lg-3 col-md-4 col-sm-4 red " id="youxiaoqi"><span>有效期</span>{{drugDetails.list.sxrq}}</li>
                                    <li class="col-lg-3 col-md-4 col-sm-4 red " id="tishi"><span>提示</span>{{drugDetails.list.jxqts}}</li>
                                </ul>
                            </div>
                            <div class="card col-sm-3">
                                <div>
                                    <div class="card-box">
                                        <div class="left">
                                            <img :src="cfg.assets+'/images/lsgl-mcard.png'" alt="">
                                            <span>{{lastname}}</span>
                                        </div>
                                        <div class="msg">
                                            <p><span>姓名：</span>{{member.theMemberInformation.kkhname}}</p>
                                            <p><span>积分：</span>{{member.theMemberInformation.jifen}}</p>
                                            <p><span>累积消费：</span>{{member.theMemberInformation.ljxfe}}</p>
                                            <p><span>手机号：</span>{{member.theMemberInformation.callnum}}</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row b-table table-wrap">
                        <table class="table table-striped form-table table-head" cellpadding="0" cellspacing="0">
                            <colgroup width="100%">
                                <col width="190">
                                <col width="100">
                                <col width="65">
                                <col width="50">
                                <col width="70">
                                <col width="60">
                                <col width="60">
                                <col width="0">
                            </colgroup>
                            <thead>
                                <tr>
                                    <th class="tl">商品名称</th>
                                    <th class="tl">商品规格</th>
                                    <th class="tr">单价</th>
                                    <th class="tr">数量</th>
                                    <th class="tr">应收金额</th>
                                    <th class="tr">实收金额</th>
                                    <th class="tr">结存数量</th>
                                    <th></th>
                                </tr>
                            </thead>
                        </table>
                        <div class="table-box" id="j_table_scroll">
                            <table class="table table-striped form-table" id='j_drugList' cellpadding="0" cellspacing="0">
                                <colgroup width="100%">
                                    <col width="190">
                                    <col width="100">
                                    <col width="65">
                                    <col width="50">
                                    <col width="70">
                                    <col width="60">
                                    <col width="60">
                                </colgroup>
                                <tbody>
                                    <tr v-for="(item,index) in mainBody" class="tc" :data-index="index" :class="{on:index==initialization.trIdx}" @click="onSelected" :data-jxqts="item.jxqts" :data-cardid='item.cardid' :data-jcshl="item.jcshl" :data-shl="item.shl" :data-koul="item.koul" :data-dj="item.dj" :data-ysje="item.ysje" :data-sshje="item.sshje" :data-sxrq="item.sxrq" :data-pihao="item.pihao" :data-shpchd="item.shpchd" :data-spmch="item.spmch" :data-shpgg="item.shpgg" :data-lshj="item.lshj" :data-lshh="item.lshh" :data-spid="item.spid" :data-sktid="item.sktid" :data-plh="item.plh" :data-spbh="item.spbh">
                                        <td align="left">{{item.spmch}}</td>
                                        <td align="left">{{item.shpgg}}</td>
                                        <td align="right">{{(item.dj).toFixed(2)}}</td>
                                        <td align="right">{{(item.shl).toFixed(2)}}</td>
                                        <td align="right">{{(item.ysje).toFixed(2)}}</td>
                                        <td align="right">{{(item.sshje).toFixed(2)}}</td>
                                        <td align="right">{{(item.jcshl).toFixed(3)}}</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="fd-msg row">
                        <div class="pull-left">
                            <div class="pager-box clearfix">
                                <div class="pull-left">共计<span class="blue">{{jiesuan.infoNum}}</span>条信息 合计<span class="blue">{{jiesuan.goodsNum}}</span>个商品</div>
                                <div class="pull-left" style="margin-left:25px;">
                                    <div class="clearfix" style="line-height: 32px;font-size:20px;">
                                        <div class="pull-left">应收金额
                                            <span class="blue">{{jiesuan.ysje}}</span>
                                        </div>
                                        <div class="pull-left">实收金额
                                            <span class="pink">{{jiesuan.sshje}}</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="b-balance f-btns">
                                <div class="btn-group">
                                    <button class="btn" id="j_cancelTrading" @click="onCancelTrading">取消交易(F6)</button>
                                    <button class="btn" @click="onCashbox">打开钱箱(F8)</button>
                                    <button class="btn" @click="onLodop">上一张小票</button>
                                    <button class="btn" id="j_negativeInventory" @click="onNegativeInventory" :data-state="1">{{negativeInventory}}</button>
                                    <button class="btn" data-toggle="modal" data-target="#myModaleditI" @click="bianjiH" v-show="huiyuanbianji">会员编辑</button>
                                    <button class="btn" data-toggle="modal" data-target="#myModal1" v-show="huiyuanzengjia">会员增加</button>
                                    <button class="btn" @click='onLodops'>{{lodops}}</button>
                                    <button class="btn" @click='Onsynchronization'>同步库存</button>
                                </div>
                            </div>
                        </div>
                        <div class="pull-right receivables-box">
                            <input type="button" class="receivables" value="收款 F12" id="j_receivables" @click="onReceivables" data-target="#md_receivables">
                        </div>
                        <i class="corner"></i>
                    </div>
                </div>
                <div class="col-lg-3 col-md-12 r-column col-xs-12">
                    <div class="r-turnover r-common">
                        <div class="r-header clearfix">
                            <div class="pull-left" style="margin-left:10px;">流水 </div>
                            <a class="pull-right bule cup" @click="onSmallTicket">打印更多小票</a>
                        </div>
                        <div class="table-wrap" style="margin-bottom:15px;overflow-y:auto;height:267px;">
                            <table class="table" style="border:none;">
                                <tbody>
                                    <tr v-for="items in nissin">
                                        <td>{{items.xshy}}
                                            <small>{{items.rq}}</small>
                                        </td>
                                        <td>{{items.jsfsmch}}</td>
                                        <td align="right">{{(items.sshje).toFixed(2)}}</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="r-announcemer r-common">
                        <div class="r-header clearfix">
                            <div class="pull-left">公告</div>
                            <a href="" class="pull-right bule">更多</a>
                        </div>
                        <ul class="mb20">
                            <li>
                                <a href="">汇芈医药公司本软件全部免费</a>
                            </li>
                            <li>
                                <a href="">2017-04-31 软件新版本发布请及时更新</a>
                            </li>
                            <li>
                                <a href="">汇芈微信端新功能上线</a>
                            </li>
                            <li>
                                <a href="">升级了2.0管理功能</a>
                            </li>
                            <li>
                                <a href="">升级了2.0搜索系统</a>
                            </li>
                        </ul>
                    </div>
                    <div class="r-aboutus r-common">
                        <ul>
                            <li>
                                <div class="l-icon">
                                    <i class="iconfont icon-gongsi"></i>
                                </div>
                                <div class="r-msg">
                                    <div class="t">技术支持</div>
                                    <p>上海汇芈医药科技有限公司</p>
                                </div>
                            </li>
                            <li>
                                <div class="l-icon">
                                    <i class="iconfont icon-dianhua"></i>
                                </div>
                                <div class="r-msg tel">
                                    <div class="t">服务热线(周一至周五 8:30-16:30)</div>
                                    <p>400-889-8892</p>
                                </div>
                            </li>
                            <li>
                                <div class="l-icon">
                                    <i class="iconfont icon-wechat-copy"></i>
                                </div>
                                <div class="r-msg weixin">
                                    <div class="t">微信公众号</div>
                                    <p class="img">
                                        <img :src="cfg.assets+'/images/erweima.jpg'" alt="">
                                    </p>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="modal fade" id="md_receivables" data-backdrop="static">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">
                                <span @click="cancelThePayment">×</span>
                                <span class="sr-only" >关闭</span>
                            </button>
                            <h4 class="modal-title">零售收款</h4>
                        </div>
                        <div class="modal-body">
                            <div class="payment-method" id="j_paymentMethod">
                                <ul>
                                    <li v-for="(item,index) in list" :data-index="index" :data-text="item.text" :class="{on:index==initialization.liIdx}" @click="onMethod">
                                        <i class="iconfont" :class="item.style"></i>
                                        <div class="text">
                                            <span class="s1">{{item.text}}</span>：
                                            <span v-show="item.text!='现金'" v-text="item.text!='现金'?item.num:bill"></span>
                                            <input v-show="item.text=='现金'" v-model="bill" id="j_bill" type="tel" :disabled="drugDetails.list.shl<0"> 元
                                        </div>
                                    </li>
                                </ul>
                                <div class="dibs" v-if="initialization.liIdx==0">
                                    <div class="form-inline">
                                        <span>找零</span>
                                        <div class="form-group">
                                            <div class="input-group"><input v-model="zhaol" id="j_zhaol" v-on:focus="onZhaolFocus" v-on:blur="onZhaolBlure"
                                                    class="form-control" type="text">
                                                <div class="input-group-addon">元</div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-inline">
                                        <span>抺零</span>
                                        <div class="form-group">
                                            <div class="input-group"><input v-model="jiesuan.moling" disabled="disabled" class="form-control" type="text">
                                                <div class="input-group-addon">元</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer" style="position: relative;">
                            <div class="pay-msg red" v-show="payMsgStatus" style="position: absolute;top:22px;left:125px;">找零金额不能大于100元</div>
                            <button type="button" class="btn btn-default" data-dismiss="modal" @click="cancelThePayment">取消</button>
                            <button type="button" class="btn btn-primary" id="j_saveTheInformation" @click="saveTheInformation" data-dismiss="modal">确定</button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 模态框（Modal）增加 -->
            <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width: 60%;margin-top: 100px;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel"><img src="../assets/_src/images/add.png" alt="">添加会员</h4>
                        </div>
                        <div class="modal-body">
                            <div class="">
                                <div class="row font-color-g">
                                    <div class="col-lg-4 col-md-4 col-sm-4">
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <span style="color:red;">✲</span>
                                                <label class="">卡号</label>
                                                <input type="text" class="form-control inputT addCardNumber">

                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>发卡日期</label>
                                                <input type="text" class="form-control inputT addData" v-model="today" readonly>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>有效期</label>
                                                <input type="text" class="form-control inputT addValidity" v-model="closingDate" readonly>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>累计消费</label>
                                                <input type="text" class="form-control inputT addCumulative" readonly>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>积分</label>
                                                <input type="text" class="form-control inputT addIntegral" readonly>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>已换积分</label>
                                                <input type="text" class="form-control inputT addInIntegral" readonly>
                                            </div>
                                        </form>
                                    </div>
                                    <div class="col-lg-4 col-md-4 col-sm-4">
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <span style="color:red;">✲</span>
                                                <label>姓名</label>
                                                <input type="text" class="form-control inputT addName">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <span style="color:red;">✲</span>
                                                <label>电话</label>
                                                <input type="text" class="form-control inputT addPhone">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5  text-right">
                                            <label>性别</label>
                                            <div class="inputT form-group sexadd">
                                                <div class="radio ">
                                                    <label>
                                
                                <input type="radio" name="optionsRadios" id="optionsRadios" v-model="gender" value="男"  > 男生
                            </label>
                                                </div>
                                                <div class="radio radioLeft">
                                                    <label>
                            <input type="radio" name="optionsRadios" id="optionsRadios2" v-model="gender"  value="女" >女生
                            </label>
                                                </div>
                                            </div>
                                        </form>
                                        <!-- <form class="form-inline margin-top5 text-right"> -->
                                        <!-- <div class="form-group ">
                            <label>出生日期</label>
                            <input type="text" class="form-control inputT addBore" readonly onfocus="showDate()" id="txt_calendar"  >
                          </div> -->
                                        <div class="control-group form-group margin-top5 text-right">
                                            <span style="color:red;">✲</span>
                                            <label class="control-label">出生日期</label>
                                            <div class="controls input-append date form_date" style="display:inline-block;" data-date="" data-date-format="yyyy-mm-dd"
                                                data-link-field="dtp_input2" data-link-format="yyyy-mm-dd">
                                                <input size="16" type="text" style="padding:0px" @change="check1" id="txt_calendar" class="data form-control">
                                                <span class="add-on"><i class="icon-remove"></i></span>
                                                <span class="add-on"><i class="icon-th"></i></span>
                                            </div>
                                            <input type="hidden" id="dtp_input2" value="" /><br/>
                                        </div>
                                        <!-- </form> -->
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>联系地址</label>
                                                <input type="text" class="form-control inputT addAddress ">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>邮箱</label>
                                                <input type="text" class="form-control inputT addEmail">
                                            </div>
                                        </form>
                                    </div>
                                    <div class="col-lg-4 col-md-4 col-sm-4">
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>慢性病史</label>
                                                <input type="text" class="form-control inputT addChronicTree">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>药物过敏史</label>
                                                <input type="text" class="form-control inputT addHistoryOfDrug">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>备注</label>
                                                <textarea class="form-control inputT preservation addRemark" rows="3"></textarea>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>是否发放会员实体卡</label>
                                                <select class="selectedHello">  
                                <option v-for="item in items"  :selected="index=1?true:false" >{{item.text}}</option>  
                            </select>
                                            </div>

                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>是否是管理员</label>
                                                <select class="selectedWarden">  
                                <option v-for="item in items" :selected="index=1?true:false" >{{item.text}}</option>  
                            </select>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-primary" @click="preservation">保存</button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 模态框（Modal）编辑 -->
            <div class="modal fade" id="myModaleditI" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width: 60%;margin-top: 100px;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">编辑</h4>
                        </div>
                        <div class="modal-body">
                            <div class="">
                                <div class="row font-color-g">
                                    <div class="col-lg-4 col-md-4 col-sm-4">
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <span style="color:red;">✲</span>
                                                <label class="" class="color:#000000">卡号</label>
                                                <input type="text" class="form-control inputT addCardNumbeq" v-model="details.kkhcode">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>发卡日期</label>
                                                <input type="text" class="form-control inputT addData" v-model="details.fkrq" readonly>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>有效期</label>
                                                <input type="text" class="form-control inputT addValidity" v-model="details.sxrq" readonly>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>累计消费</label>
                                                <input type="text" class="form-control inputT addCumulative" v-model="details.ljxfe" readonly>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>积分</label>
                                                <input type="text" class="form-control inputT addIntegral" v-model="details.jifen" readonly>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>已换积分</label>
                                                <input type="text" class="form-control inputT addInIntegral" v-model="details.ydjifen" readonly>
                                            </div>
                                        </form>
                                    </div>
                                    <div class="col-lg-4 col-md-4 col-sm-4">
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <span style="color:red;">✲</span>
                                                <label>姓名</label>
                                                <input type="text" class="form-control inputT addNameq" v-model="details.kkhname">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <span style="color:red;">✲</span>
                                                <label>电话</label>
                                                <input type="text" class="form-control inputT addPhoneq" v-model="details.callnum">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5  text-right">
                                            <label style="color:#444;font-weight:normal">性别</label>
                                            <div class="inputT form-group sexadd">
                                                <div class="radio ">
                                                    <label>
                                <input type="radio" name="optionsRadios" id="optionsRadios1" v-model="details.sexid" value="男" > 男生
                            </label>
                                                </div>
                                                <div class="radio radioLeft">
                                                    <label>
                                <input type="radio" name="optionsRadios" id="optionsRadios2" v-model="details.sexid" value="女">女生
                            </label>
                                                </div>
                                            </div>
                                        </form>
                                        <div class="control-group form-group margin-top5 text-right">
                                            <span style="color:red;">✲</span>
                                            <label class="control-label">出生日期</label>
                                            <div class="controls input-append date form_date" style="display:inline-block;" data-date="" data-date-format="yyyy-mm-dd"
                                                data-link-field="dtp_input2" data-link-format="yyyy-mm-dd">
                                                <input size="16" type="text" style="padding:0px;" @change="check2" id="txt_calendar" class="data form-control">
                                                <span class="add-on"><i class="icon-remove"></i></span>
                                                <span class="add-on"><i class="icon-th"></i></span>
                                            </div>
                                            <input type="hidden" id="dtp_input2" value="" /><br/>
                                        </div>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>联系地址</label>
                                                <input type="text" class="form-control inputT addAddress " v-model="details.zyaddress">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>邮箱</label>
                                                <input type="text" class="form-control inputT addEmail " v-model="details.email">
                                            </div>
                                        </form>
                                    </div>
                                    <div class="col-lg-4 col-md-4 col-sm-4">
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>慢性病史</label>
                                                <input type="text" class="form-control inputT addChronicTree" v-model="details.manxbs">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>药物过敏史</label>
                                                <input type="text" class="form-control inputT addHistoryOfDrug" v-model="details.yongygms">
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>备注</label>
                                                <textarea class="form-control inputT preservation addRemark" rows="3" v-model="details.beizhu"></textarea>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>是否发放会员实体卡</label>

                                                <select class="form-control selectedHello1" id="is_faka">

                                    <option v-for=" item in items" :value="item.value" class="">{{item.text}}</option>
                                </select>
                                            </div>
                                        </form>
                                        <form class="form-inline margin-top5 text-right">
                                            <div class="form-group ">
                                                <label>是否是管理员</label>

                                                <select class="form-control selectedWarden1" id="boss">

                                    <option v-for=" item in items" :value="item.value" class="">{{item.text}}</option>
                                </select>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-primary " @click="saveEditAdd">保存</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal fade small-pop" id="md_pops" data-backdrop="static">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">
                                <span aria-hidden="true">×</span>
                                <span class="sr-only" >关闭</span>
                            </button>
                            <h4 class="modal-title">消息</h4>
                        </div>
                        <div class="modal-body" style="padding:25px 150px 0 150px;">
                            <div class="title text-center f16 b" style="margin-bottom:20px;">交易成功，谢谢</div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-primary" data-dismiss="modal" id='fansi'>确定</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="lodop-box" id="lodopBxo1" style="position: fixed;left:-300px;visibility:hidden;">
                <div class="title" style="line-height:1.2;font-size:12px;text-align:center">【棉棉生活馆-收银凭条】</div>
                <div>
                    <p style="line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap;margin:0;height:14px;"><span>日期:{{printData.time1}}</span><span>时间:{{printData.time2}}</span></p>
                    <p style="line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap;margin:0;height:14px;"><span style="width:40%;float:left;">收银员:{{printData.shky}}</span><span class="fr" style="width:60%;float:right;">流水号:{{printData.liushui}}</span></p>
                    <p style="line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap;height:14px;"><span style="width:50%;float:left;">会员名:{{printData.kkhname}}</span><span style="width:50%;float:right;">积分:{{printData.jifen}}</span></p>
                </div>
                <hr style="margin:3px;">
                <table width="100%" style="table-layout:fixed">
                    <tr style="text-align: center;">
                        <td width='50%' style="line-height:1.2;font-size:12px;">商品名称</td>
                        <td width='20%' style="line-height:1.2;font-size:12px;">数量</td>
                        <td  width='30%' style="line-height:1.2;font-size:12px;">金额</td>
                    </tr>
                    <tr v-for="(item,index) in printData.list">
                        <td  width='50%' style="line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap;">{{item.spmch}}</td>
                        <td style="text-align:right;line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap;" width='20%'>{{item.shl}}</td>
                        <td width='30%'  style="text-align:right;line-height:1.2;font-size:12px;overflow:hidden;white-space:nowrap;">{{jiesuan.sshje}}</td>
                    </tr>
                </table>
                <hr style="margin:3px;">
                <div style="position: relative;white-space: nowrap">
                    <div class='clearfix'>
                        <div style="width:55%;float: left;">
                            <p style="margin:0;line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap">收款金额:{{printData.bill}}</p>
                            <p style="margin:0;line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap">实收金额:{{printData.sshje}}</p>
                        </div>
                        <div style="width:45%;float: left">
                            <p style="margin:0;line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap">找零金额:{{printData.zhaol}}</p>
                            <p style="margin:0;line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap">抹零金额:{{printData.moling}}</p>
                        </div>
                    </div>
                    <div class='clearfix'>
                        <p style="margin:0;line-height:1.2;font-size:12px;width:55%;float: left;overflow:hidden;white-space: nowrap">会员优惠:{{printData.discount}}</p>
                        <p style="margin:0;line-height:1.2;font-size:12px;width:45%;float: left;overflow:hidden;white-space: nowrap">收讫：{{printData.jsfsmch}}</p>
                    </div>
                </div>
                <p style="margin:0;line-height:1.2;font-size:12px;text-align:center">好袜子！好生活！</p>
                <p style="margin:0;line-height:1.2;font-size:12px;text-align:center">祝您购物愉快！</p>    
                <p style="margin:0;line-height:1.2;font-size:12px;">地址：浦东新区龙阳广场2层</p>
                <hr>
            </div>
            <div class="lodop-box" id="lodopBxo2" style="position: fixed;left:-300px;visibility:hidden;">
                <p style="margin:0;line-height:1;font-size:12px;text-align:center">【汇美医保卖场-收银凭条】</p>
                <div>
                    <p style="line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap;margin:0;height:14px;"><span>日期:{{printData.time1}}</span><span>时间:{{printData.time2}}</span></p>
                    <p style="line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap;margin:0;height:14px;"><span style="width:40%;float:left;">收银员:{{printData.shky}}</span><span style="width:60%;float:right;">流水号:{{printData.liushui}}</span></p>
                    <p style="line-height:1.2;font-size:12px;overflow:hidden;white-space: nowrap;margin:0;height:14px;"><span style="width:50%;float:left;">会员名:{{printData.kkhname}}</span><span style="width:50%;float:right;">积分:{{printData.jifen}}</span></p>
                </div>
                <hr style="margin:3px;">
                <table width="100%" style="table-layout:fixed">
                    <tbody v-for="(item,index) in printData.list">
                        <tr><td style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap;" colspan="2">品名:{{item.spmch}}</td></tr>
                        <tr>
                            <td style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap;" width='50%'>售价/会员价{{parseFloat(item.lshj).toFixed(2)}}/{{parseFloat(item.dj).toFixed(2)}}</td>
                            <td style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap;" width='50%'>数量:{{parseFloat(item.shl).toFixed(2)}}</td>
                        </tr>
                        <tr>
                            <td style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap;" width='50%'>小计:{{parseFloat(item.sshje).toFixed(2)}}</td>
                            <td style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap;" width='50%'>规格:{{item.shpgg}}</td>
                        </tr>
                        <tr>
                            <td style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap;" width='50%'>批号:{{item.pihao}}</td>
                            <td style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap;" width='50%'>产地:{{item.shpchd}}</td>
                        </tr>
                    </tbody>
                </table>
                <hr>
                <div style="position: relative;white-space: nowrap">
                    <div class='clearfix'>
                        <div style="width:55%;float: left;">
                            <p style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap">收款金额:{{printData.bill}}</p>
                            <p style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap">实收金额:{{printData.sshje}}</p>
                        </div>
                        <div style="width:45%;float: left">
                            <p style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap">找零金额:{{printData.zhaol}}</p>
                            <p style="margin:0;line-height:1;font-size:12px;overflow:hidden;white-space: nowrap">抹零金额:{{printData.moling}}</p>
                        </div>
                    </div>
                    <div class='clearfix'>
                        <p style="margin:0;line-height:1;font-size:12px;width:55%;float: left;overflow:hidden;white-space: nowrap">会员优惠:{{printData.discount}}</p>
                        <p style="margin:0;line-height:1;font-size:12px;width:45%;float: left;overflow:hidden;white-space: nowrap">收讫：{{printData.jsfsmch}}</p>
                    </div>
                </div>
                <p style="margin:0;line-height:1;font-size:12px;text-align:center">*为运动员慎用、*#为含麻类药品</p>
                <p style="margin:0;line-height:1;font-size:12px;text-align:center">(非质量问题，概不退换)</p>
                <p style="margin:0;line-height:1;font-size:12px;text-align:center">祝您购物愉快！</p>    
                <p style="margin:0;line-height:1;font-size:12px;">地址:浦东新区高桥镇花山路696号</p>
                <p style="margin:0;line-height:1;font-size:12px;">电话:021-58696511</p>
                <hr>
            </div>
        </div>
    </div>
    </div>
</template>
<script>
    let who = "",
        bfocus = false,
        bblur = false,
        execTime = 1,
        s_to_z = 0,
        sell_suc = 0,
        a_to_c = 0,
        tmp_count = 1,
        tmp_discount = 100,
        tmp_price = 0,
        payStatus = false,
        listStatus = false,
        dingPay = true;
    import bus from "../api/eventBus";
    import {
        setUi,
        setUserInfo,
        setMainTable,
        setpopPerfect
    } from "../vuex/actions";
    import {
        ui,
        userInfo,
        mainTable,
        popPerfect
    } from "../vuex/getters";
    export default {
        vuex: {
            getters: {
                ui,
                userInfo,
                mainTable,
                popPerfect
            },
            actions: {
                setUi,
                setUserInfo,
                setMainTable,
                setpopPerfect
            }
        },
        components: {},
        data() {
            return {
                list: [{
                    style: "icon-qian3",
                    text: "现金",
                    num: 0.0
                }, {
                    style: "icon-umidd17",
                    text: "支付宝",
                    num: 0.0
                }, {
                    style: "icon-icon-",
                    text: "微信",
                    num: 0.0
                }, {
                    style: "icon-yinlian",
                    text: "银联",
                    num: 0.0
                }],
                initialization: {
                    //页面初始化加载的数据
                    fdbsMap: {}, //分店标识
                    theSalesman: {}, //销售员
                    department: {}, //货位部门
                    huowei: {}, //货位
                    cashier: {
                        name: "", //收银name
                        xshy: "",
                        sktid: "", //收银编码
                        shkyid: "" //收银员内码
                    },
                    liushui: "", //最终流水号
                    lsNum: 0,
                    mainHead: [], //主体表格头部
                    liIdx: 0,
                    adminid: true, //店长标识
                    trIdx: 0,
                    setConfig: {
                        //配置信息（库存，扣率，自动结算）
                        kucun: {},
                        tuihuo: {},
                        tijiao: {},
                        koulv: {}
                    }
                },
                items: [{
                    text: "是",
                    value: "1"
                }, {
                    text: "否",
                    value: "0"
                }],
                sex: [{
                    text: "男生",
                    value: "1"
                }, {
                    text: "女生",
                    value: "0"
                }],
                details: {},
                changeValue: {
                    searchMsg: "" //搜索词条
                },
                plh: 0, //设置localStorage排列号
                member: {
                    huiyuanid: "", //会员ID
                    theMemberInformation: {} //会员信息
                },
                mainBody: [], //主体表格内容
                bill: 0,
                payMsgStatus: false,
                payMsg: '',
                zhaol: 0, //找零
                zdkoul: 0, //整单扣率
                lodops: '',
                jiesuan: {
                    //收款金额
                    ysje: 0, //应该收金额
                    sshje: 0, //实收金额
                    infoNum: 0, //信息条数
                    goodsNum: 0, //信息条数
                    moling: 0 //抹零
                },
                nissin: {},
                djMsg: "",
                shlMsg: "",
                koulMsg: "",
                Adorn1: false,
                Adorn2: false,
                drugDetails: {
                    list: {}
                }, //商品详情
                popBody: ``,
                popMsg: `<p>哈哈哈</p>`,
                searchText: "搜索商品(F2)",
                negativeInventory: "允许自动提交",
                paymentMethods: {},
                paymentMethodsA: {},
                printData: {
                    item: "",
                    cashier: "",
                    huiyuan: "",
                    ydjifen: 1520.12,
                    list: {},
                    discount: ""
                },
                today: "",
                closingDate: "",
                sktId: "",
                huiyuanbianji: false,
                huiyuanzengjia: true,
                gender: '男'
            };
        },
        watch: {
            mainBody(nv, ov) {
                let me = this;
                me.jiesuan.infoNum = me.mainBody.length;
                me.onSettlement();
            },
            bill(nv, ov) {
                let me = this;
                let {
                    shkje,
                    sshje
                } = me.jiesuan;
                if (nv != ov) {
                    if (nv <= sshje) {
                        me.zhaol = 0;
                        console.log(123, me.zhaol);
                        me.$set(me.jiesuan, "moling", (sshje - nv).toFixed(2));
                    } else {
                        me.zhaol = Math.round((nv - sshje) * 100) / 100;
                        me.$set(me.jiesuan, "moling", (nv - sshje - me.zhaol).toFixed(2));
                    }
                    if (me.bill - me.jiesuan.sshje >= 100) {
                        me.payMsgStatus = true;
                    } else {
                        me.payMsgStatus = false;
                    }
                }
            },
            zhaol(nv, ov) {
                console.log('去死')
                if (nv != ov) {
                    let me = this;
                    let {
                        shkje,
                        sshje
                    } = me.jiesuan;
                    me.$set(me.jiesuan, "moling", (me.bill - sshje - me.zhaol).toFixed(2));
                }
            }
        },
        methods: {
            onQuantityBlur(e) { //修改数量
                let me = this;
                let trOn = $("#j_drugList").find(".on");
                who = "修改数量";
                bfocus = false;
                bblur = true;
                if (me.mainBody.length > 0) {
                    let consfig = JSON.parse(localStorage.getItem("consfig"));
                    let trPlh = trOn.attr("data-plh");
                    if (me.drugDetails.list.shl == "" || me.drugDetails.list.shl == 0) {
                        me.mainBody.forEach((item, index) => {
                            if (item.plh == trPlh) {
                                return Vue.set(me.mainBody, index, me.mainBody[index]);
                            }
                            return item;
                        });
                        me.drugDetails.list.shl = consfig.shl;
                    }
                    if (me.initialization.setConfig.kucun.value == 0) {
                        if (me.drugDetails.list.shl - consfig.shl > trOn.attr("data-jcshl")) {
                            me.mainBody.forEach((item, index) => {
                                if (item.plh == trPlh) {
                                    return Vue.set(me.mainBody, index, me.mainBody[index]);
                                }
                                return item;
                            });
                            me.drugDetails.list.shl = consfig.shl;
                            tmp_count = consfig.shl;
                            bfocus = true;
                            me.shlMsg = "不允许负库存";
                            $("#k_alt_s").focus();
                            return;
                        } else {
                            me.shlMsg = "";
                            $("#j_searchDrug").focus();
                        }
                    }
                    if (me.drugDetails.list.shl != tmp_count) {
                        tmp_count = me.drugDetails.list.shl;
                        let res = {
                            shuliang: me.drugDetails.list.shl,
                            lshh: trOn.attr("data-lshh"),
                            spid: trOn.attr("data-spid"),
                            sktid: trOn.attr("data-sktid"),
                            fdbs: me.initialization.fdbsMap.fdbs,
                            plh: trPlh
                        }
                        me.service.updateTmpPosMxlsShuLiang(me, res, data => {
                            if (data.code == 1) {
                                me.mainBody = me.mainBody.map((item, index) => {
                                    if (item.plh == trPlh) {
                                        return me.$set(me.mainBody, index, data.data);
                                    }
                                    return item;
                                });
                            } else if (data.code == -1) {
                                me.drugDetails.list.shl = consfig.shl;
                                me.shlMsg = data.msg;
                                $("#k_alt_s").focus();
                                return;
                            }
                            me.shlMsg = "";
                            for (let i in consfig) {
                                if (i == "shl") {
                                    consfig[i] = me.drugDetails.list.shl;
                                }
                            }
                            localStorage.setItem("consfig", JSON.stringify(consfig));
                        })
                        $("#j_searchDrug").focus();
                    }
                } else {
                    $("#j_searchDrug").focus();
                }
            },
            onQuantityFocus(e) { //修改数量得到焦点
                let me = this;
                who = "修改数量";
                bfocus = true;
                bblur = false;
            },
            onPriceBlur(e) { //修改单价
                let me = this;
                who = "单价";
                bfocus = false;
                bblur = true;
                let o = $("#j_drugList").find("tr.on");
                let trPlh = o.attr("data-plh");
                let consfig = JSON.parse(localStorage.getItem("consfig"));
                if (me.mainBody.length > 0) {
                    if (me.drugDetails.list.dj < me.initialization.setConfig.koulv.value / 100 * o.attr("data-lshj")) {
                        me.mainBody.forEach((item, index) => {
                            if (item.plh == trPlh) {
                                return Vue.set(me.mainBody, index, me.mainBody[index]);
                            }
                            return item;
                        });
                        me.drugDetails.list.dj = consfig.dj;
                        tmp_price = consfig.dj;
                        bfocus = true;
                        me.djMsg = `单价不能低于${me.initialization.setConfig.koulv.value / 100 * o.attr("data-lshj")}`;
                        $("#k_alt_d").focus();
                    } else {
                        console.log(me.drugDetails.list.dj, tmp_price);
                        if (me.drugDetails.list.dj != tmp_price) {
                            tmp_price = me.drugDetails.list.dj;
                            let res = {
                                danJia: me.drugDetails.list.dj,
                                lshh: o.attr("data-lshh"),
                                spid: o.attr("data-spid"),
                                sktid: o.attr("data-sktid"),
                                fdbs: me.initialization.fdbsMap.fdbs,
                                plh: trPlh
                            }
                            me.service.updateTmpPosMxlsDanJia(me, res, data => {
                                me.djMsg = "";
                                me.mainBody = me.mainBody.map((item, index) => {
                                    if (item.plh == trPlh) {
                                        return me.$set(me.mainBody, index, data.data);
                                    }
                                    return item;
                                });
                                me.drugDetails.list.koul = data.data.koul;
                                for (let i in consfig) {
                                    if (i == "dj") {
                                        consfig[i] = me.drugDetails.list.dj;
                                    }
                                }
                                localStorage.setItem("consfig", JSON.stringify(consfig));
                            });
                        }
                        $("#j_searchDrug").focus();
                    }
                } else {
                    $("#j_searchDrug").focus();
                }
            },
            onPriceFocus(e) { //修改单价得到焦点
                let me = this;
                who = "单价";
                bfocus = true;
                bblur = false;
            },
            onDiscountBlur(e) { //修改扣率
                let me = this;
                let o = $("#j_drugList").find(".on");
                let trPlh = o.attr("data-plh");
                who = "折扣率";
                bfocus = false;
                bblur = true;
                console.log(me.drugDetails, 9999999);
                let consfig = JSON.parse(localStorage.getItem("consfig"));
                if (me.mainBody.length > 0) {
                    if (me.initialization.setConfig.koulv.value > me.drugDetails.list.koul) {
                        me.mainBody.forEach((item, index) => {
                            if (item.plh == trPlh) {
                                return Vue.set(me.mainBody, index, me.mainBody[index]);
                            }
                            return item;
                        });
                        tmp_discount = consfig.koul;
                        bfocus = true;
                        $("#k_alt_c").focus();
                        me.drugDetails.list.koul = consfig.koul;
                        me.koulMsg = "最低扣率不能小于" + me.initialization.setConfig.koulv.value;
                    } else {
                        if (me.drugDetails.list.koul != tmp_discount) {
                            tmp_discount = me.drugDetails.list.koul;
                            let res = {
                                kouLv: me.drugDetails.list.koul,
                                lshh: o.attr("data-lshh"),
                                spid: o.attr("data-spid"),
                                sktid: o.attr("data-sktid"),
                                fdbs: me.initialization.fdbsMap.fdbs,
                                plh: trPlh
                            }
                            me.service.updateTmpPosMxlsKouLv(me, res, data => {
                                me.koulMsg = "";
                                me.mainBody = me.mainBody.map((item, index) => {
                                    if (item.plh == trPlh) {
                                        return Vue.set(me.mainBody, index, data.data);
                                    }
                                    return item;
                                });
                                for (let i in consfig) {
                                    if (i == "koul") {
                                        consfig[i] = me.drugDetails.list.koul;
                                    }
                                }
                                me.drugDetails.list.dj = data.dj;
                                localStorage.setItem("consfig", JSON.stringify(consfig));
                            });
                        }
                        $("#j_searchDrug").focus();
                    }
                } else {
                    $("#j_searchDrug").focus();
                }
            },
            onDiscountFocus(e) { //修改扣率得到焦点
                let me = this;
                who = "折扣率";
                bfocus = true;
                bblur = false;
            },
            onZhaolBlure(e) { //找零失去得到焦点
                let me = this;
                who = "找零";
                bfocus = false;
                bblur = true;
                console.log(s_to_z, bfocus, execTime, who, "找零失去焦点");
            },
            onZhaolFocus(e) { //找零得到焦点
                let me = this;
                who = "找零";
                bfocus = true;
                bblur = false;
                execTime = 1;
                console.log(s_to_z, bfocus, execTime, who, "找零得到焦点");
            },
            onSelected(e) { //选中商品操作
                let me = this;
                let o = $(e.currentTarget);
                let {
                    index
                } = e.currentTarget.dataset;
                me.initialization.trIdx = index;
                me.drugDetails.list = e.currentTarget.dataset;
                let trs = $("#j_drugList").find(".on");
                let shl = trs.attr("data-shl");
                let dj = trs.attr("data-dj");
                let koul = trs.attr("data-koul");

                localStorage.setItem("consfig", JSON.stringify({
                    shl: shl,
                    dj: dj,
                    koul: koul
                }));
                tmp_discount = me.drugDetails.list.koul;
                tmp_price = me.drugDetails.list.dj;
                tmp_count = me.drugDetails.list.shl;
            },
            onSwitch(e) { //搜索切换
                let me = this;
                if (me.searchText == "搜索会员(F2)") {
                    me.searchText = "搜索商品(F2)";
                } else {
                    me.searchText = "搜索会员(F2)";
                }
                me.changeValue.searchMsg = "";
            },
            onSearchDrug(e) { //商品搜索
                let me = this;
                $("#j_searchDrug").autocomplete({
                    source(request, response) {
                        if (me.changeValue.searchMsg != '') {
                            if (me.changeValue.searchMsg == ' ') {
                                me.changeValue.searchMsg = '';
                            }
                            me.service.selectSPInfoFuzzy(me, response);
                        }
                    },
                    minLength: 0,
                    select: function(event, ui) {
                        let o = $(event.currentTarget);
                        me.service.insertTmpPosMxls(me, ui);
                    },
                    response: function(event, ui) {
                        if (ui.content.length == 1) {
                            setTimeout(function() {
                                $(".ui-menu li:first").trigger("click");
                            }, 0);
                        }
                    }
                });
            },
            onAdorn1(e) {
                let me = this;
                if (!me.Adorn1) {
                    layer.alert('未查找到相关商品');
                }
            },
            onAdorn2(e) {
                let me = this;
                console.log(me.Adorn2);
                if (!me.Adorn2) {
                    layer.alert('未查找到会员信息');
                }
            },
            onSearchMember(e) { //会员搜索
                let me = this;
                if (me.mainBody.length > 0) {
                    alert("请先选择会员，再输入商品");
                } else {
                    $("#j_searchMember").autocomplete({
                        source(request, response) {
                            me.service.selectHuiYuanFuzzy(me, response);
                        },
                        select: function(event, ui) {
                            me.service.selectHuiYuanDetail(me, ui, data => {
                                me.member.huiyuanid = data.data.cardid;
                                me.member.theMemberInformation = ui.item;
                                // setItemMethod("member", me.member.theMemberInformation);
                                console.log(ui, 123123123123);
                                me.changeValue.searchMsg = "";

                                me.motai = true;
                                me.huiyuanbianji = true;
                                me.huiyuanzengjia = false;
                                me.zdkoul = ui.item.zdkoul
                                me.onSwitch();
                                me.onSurname();
                                setTimeout(function() {
                                    $("#j_searchDrug").focus();
                                }, 0);
                            });
                        }
                    });
                }
            },
            bianjiH(e) { // 模糊查询会员信息
                let me = this;
                if (me.motai == true) {
                    var parmsa = {
                        kkhcode: me.member.theMemberInformation.kkhcode,
                        callnum: me.member.theMemberInformation.callnum,
                        kkhname: me.member.theMemberInformation.kkhname,
                        page: 1,
                        rows: 10
                    };
                    console.log(parmsa);
                    $.ajax({
                        type: "get",
                        url: me.cfg.api + "/huiyuan/selectOneHuiyuan",
                        data: parmsa,
                        dataType: "json"
                    }).done(function(data) {
                        console.log("===模糊查询会员信息===");
                        console.log(data);
                        me.cardCode = data.data.list;
                        console.log(me.cardCode);
                        for (let i = 0; i < me.cardCode.length; i++) {
                            me.details = me.cardCode[0];
                            console.log(me.details, "编辑会员");
                        }
                        if (me.details.boss == 1) {
                            $("#boss option[value='1']").attr("selected", "selected");
                        } else {
                            $("#boss option[value='0']").attr("selected", "selected");
                        }
                        if (me.details.is_faka == "是") {
                            $("#is_faka option[value='1']").attr("selected", "selected");
                        } else {
                            $("#is_faka option[value='0']").attr("selected", "selected");
                        }
                        me.onSurname();
                    });
                } else {}
            },
            saveEditAdd(e) {
                let me = this;
                let req = /^1[3|4|5|7|8][0-9]{9}$/; //手机号的正则验证
                // 编辑会员信息
                me.cardAddq = $(".addCardNumbeq").val();
                me.nameAddq = $(".addNameq").val();
                me.phoneAddq = $(".addPhoneq").val();

                me.selectedHello = $('.selectedHello1').val();
                me.selectedWarden = $('.selectedWarden1').val();
                if (me.selectedWarden == "1") {
                    me.selectedWarden = "1";
                } else {
                    me.selectedWarden = "0";
                }
                if (me.selectedHello == "1") {
                    me.selectedHello = "是";
                } else {
                    me.selectedHello = "否";
                }

                var def = 1;
                $("input[type=radio][name=def][value='" + def + "']").prop(
                    "checked",
                    true
                );
                if (me.cardAddq == "") {
                    layer.alert("会员卡号不能为空");
                    return false;
                } else {
                    if (me.cardAddq != me.details.kkhcode) {
                        $.ajax({
                            type: "get",
                            url: me.cfg.api + "/huiyuan/selectOneKkhcode",
                            data: {
                                kkhcode: me.cardAddq
                            },
                            dataType: "json"
                        }).done(function(data) {
                            console.log("===校验会员卡号===");
                            console.log(data);
                            me.cardServerce = data.data;
                            if (!(data.data == null)) {
                                layer.alert("您的会员卡号已存在");
                                return false;
                            }
                        });
                    }

                }
                if (me.nameAddq == "") {
                    layer.alert("姓名不能为空");
                    return false;
                }
                if (me.phoneAddq == "") {
                    layer.alert("手机号不能为空");
                    return false;
                } else {
                    if (me.phoneAddq != me.details.callnum) {
                        $.ajax({
                            type: "get",
                            url: me.cfg.api + "/huiyuan/selectOneCallnum",
                            data: {
                                callnum: me.phoneAddq
                            },
                            dataType: "json"
                        }).done(function(data) {
                            me.phoneServerce = data.data;
                            if (!(data.data == null)) {
                                layer.alert("您的手机号已存在");
                                return false;
                            }
                        });
                    }

                }
                let parms = {
                    cardid: me.details.cardid, //会员号
                    kkhcode: me.cardAddq, //会员卡号
                    kkhname: me.nameAddq, //会员姓名
                    sxrq: me.details.sxrq, //会员卡失效日期
                    beizhu: $(".addRemark").val(), //备注
                    koulv: me.details.koulv, //会员折扣率（默认100）
                    is_faka: me.selectedHello, //是否发放实体会员卡
                    fdbs: me.initialization.fdbsMap.fdbs, //分店标识
                    crsq: $("#txt_calendar").val(), //出生日期
                    callnum: me.phoneAddq, //手机号
                    zyaddress: $(".addAddress").val(), //家庭地址
                    manxbs: $(".addChronicTree").val(), //慢性病史
                    yongygms: $(".addHistoryOfDrug").val(), //用药过敏史
                    sexid: me.gender, //性别
                    boss: me.selectedWarden, //是否是管理员（是：1，否 0）
                    email: $('.addEmail').val()
                };
                console.log(parms, "000000");
                $.ajax({
                    type: "post",
                    url: me.cfg.api + "/huiyuan/updateHuiyuan",
                    data: parms,
                    dataType: "json"
                }).done(function(data) {
                    console.log("===编辑会员信息===");
                    console.log(data);

                    if (data.data == 1) {
                        $("#myModaleditI").modal("hide");
                        $.ajax({
                            type: "get",
                            url: me.cfg.api + "/huiyuan/selectHuiYuanDetail",
                            data: {
                                cardid: me.details.cardid
                            },
                            dataType: "json"
                        }).done(function(data) {
                            console.log("===编辑会员成功===");
                            console.log(data);
                            me.member.theMemberInformation = data.data;
                            me.details1 = data.data;

                            me.onSurname();
                        });
                    } else {
                        layer.alert("编辑会员不成功!");
                    }
                });
            },
            preservation(e) {
                let me = this;
                me.kk = "ll123";
                let re = /^1[3|4|5|7|8][0-9]{9}$/; //手机号的正则验证
                // 增加会员信息
                me.cardAdd = $(".addCardNumber").val();
                me.nameAdd = $(".addName").val();
                me.phoneAdd = $(".addPhone").val();

                me.selectedWarden = $('.selectedWarden').val(); //是否是管理员
                me.selectedHello = $('.selectedHello').val(); //是否发会员卡
                if (me.selectedWarden == "是") {
                    me.selectedWarden = "1";
                } else {
                    me.selectedWarden = "0";
                }
                if (me.cardAdd == "") {
                    layer.alert("会员卡号不能为空");
                    return false;
                } else {
                    $.ajax({
                        type: "get",
                        url: me.cfg.api + "/huiyuan/selectOneKkhcode",
                        data: {
                            kkhcode: me.cardAdd
                        },
                        dataType: "json"
                    }).done(function(data) {
                        console.log("===校验会员卡号===");
                        console.log(data);
                        me.cardServerce = data.data;
                        if (!(data.data == null)) {
                            layer.alert("您的会员卡号已存在");
                            return false;
                        }
                    });
                }
                if (me.nameAdd == "") {
                    layer.alert("姓名不能为空");
                    return false;
                }
                if (me.phoneAdd == "") {
                    layer.alert("手机号不能为空");
                    return false;
                } else if (!re.test(me.phoneAdd)) {
                    layer.alert("请输入正确的手机号");
                    return false;

                } else {
                    $.ajax({
                        type: "get",
                        url: me.cfg.api + "/huiyuan/selectOneCallnum",
                        data: {
                            callnum: me.phoneAdd
                        },
                        dataType: "json"
                    }).done(function(data) {
                        me.phoneServerce = data.data;
                        if (!(data.data == null)) {
                            layer.alert("您的手机号已存在");
                            return false;
                        }
                    });

                }
                let parms = {
                    cardid: me.member.huiyuanid, //会员号
                    kkhcode: me.cardAdd, //会员卡号
                    kkhname: me.nameAdd, //会员姓名
                    sxrq: me.closingDate, //会员卡失效日期
                    beizhu: $(".addRemark").val(), //备注
                    koulv: 100, //会员折扣率（默认100）
                    is_faka: me.selectedHello, //是否发放实体会员卡
                    fdbs: me.initialization.fdbsMap.fdbs, //分店标识
                    crsq: $("#txt_calendar").val(), //出生日期
                    callnum: me.phoneAdd, //手机号
                    zyaddress: $(".addAddress").val(), //家庭地址
                    manxbs: $(".addChronicTree").val(), //慢性病史
                    yongygms: $(".addHistoryOfDrug").val(), //用药过敏史
                    sexid: me.gender, //性别
                    boss: me.selectedWarden, //是否是管理员（是：1，否 0）
                    email: $('.addEmail').val()
                };
                console.log(parms, '增加会员信息');
                $.ajax({
                    type: "post",
                    url: me.cfg.api + "/huiyuan/insertHuiyuan",
                    data: parms,
                    dataType: "json"
                }).done(function(data) {
                    console.log("===增加会员信息===");
                    console.log(data);
                    console.log(me.gender);

                    if (data.data == 1) {
                        console.log(me.cardCode);
                        me.huiyuanbianji = true;
                        me.huiyuanzengjia = false;
                        me.motai = true;
                        // 模糊查询会员信息
                        $.ajax({
                            type: "get",
                            url: me.cfg.api + "/huiyuan/selectOneHuiyuan",
                            data: {
                                kkhcode: me.cardAdd,
                                callnum: me.phoneAdd,
                                kkhname: me.nameAdd,
                                page: 1,
                                rows: 10
                            },
                            dataType: "json"
                        }).done(function(data) {
                            console.log("===模糊查询会员信息===");
                            console.log(data);
                            me.cardCode = data.data.list;
                            for (let i = 0; i < me.cardCode.length; i++) {
                                me.member.theMemberInformation = me.cardCode[0];
                                me.details = me.cardCode[0];
                                console.log(me.member.theMemberInformation);
                                console.log(me.details);
                            }

                            me.onSurname();
                            $("#myModal1").modal("hide");
                        });

                    } else {
                        layer.alert("增加会员不成功!");
                    }
                });
            },
            onSettlement(e) { //结算金额
                let me = this;
                let ysjes = 0;
                let sshjes = 0;
                let shls = 0;
                me.mainBody.forEach((item, index) => {
                    ysjes += parseFloat(item.ysje);
                    sshjes += parseFloat(item.sshje);
                    shls += parseFloat(item.shl);
                });
                me.jiesuan.ysje = ysjes.toFixed(2) ;
                me.jiesuan.sshje = Math.round(sshjes * 100) / 100;
                me.bill = Math.round(sshjes * 10) / 10
                me.jiesuan.goodsNum = shls;
                me.list.forEach((item, index) => {
                    item.num = sshjes.toFixed(2);
                });
            },
            onMethod(e) { //选择收款类型
                let me = this;
                let {
                    index,
                    text
                } = e.currentTarget.dataset;
                let o = $(e.currentTarget);
                me.initialization.liIdx = index;
                me.paymentMethods = me.paymentMethodsA[index];
                if (text == "现金") {
                    o.find("input").focus().select();
                } else {
                    me.bill = me.jiesuan.sshje;
                }
            },
            cancelThePayment(e) { //取消收款接口
                let me = this;
                payStatus = false;
                me.service.deleteBySktid(me);
                $('#j_searchDrug').focus();
            },
            onReceivables(e) { // 保存收款信息接口
                let me = this;
                if (me.mainBody.length > 0) {
                    $("#md_receivables").modal("show");
                    $('#j_searchDrug').blur();
                    // $('#j_paymentMethod').find('li:first').trigger('click');
                    payStatus = true;
                    me.service.selectTmpPosMast(me);
                    $(document).keydown(function(event) {
                        let key = event.keyCode;
                        if (key == 27) {
                            //Esc取消交易
                            me.cancelThePayment();
                            // $("#j_searchDrug").focus();
                            $("#md_receivables").modal("hide");
                            event.returnValue = false;
                        }
                    });
                    let res = {
                        lshh: me.initialization.liushui, //	流水号
                        sktid: me.initialization.cashier.sktid, //	收款台内码
                        cardid: me.member.huiyuanid, //	优惠卡内码
                        shky: me.initialization.cashier.shky, //	收款员
                        shkyid: me.initialization.cashier.shkyid, //	收款员内码
                        xshy: $("#k_alt_y option:selected").text(), //	销售员
                        xshyid: $("#k_alt_y option:selected").val(), //	销售员内码
                        hw: $("#k_alt_z option:selected").val(), //货位内码
                        huowname: $("#k_alt_z option:selected").text(), //货位名称
                        bm: $("#k_alt_m option:selected").text(), //	部门名称
                        gzbz: "gz", //	挂帐标志
                        mx_count: "2", //	明细条数me.jiesuan.infoNum
                        je_count: "1", //	金额条数me.jiesuan.goodsNum
                        jishu: "0", //	药方剂数
                        koul: me.drugDetails.list.koul, //	扣率
                        ysje: me.jiesuan.ysje, //	应收金额
                        sshje: me.jiesuan.sshje, //	实收金额
                        // lsbh 	流水编号？？？
                        fdbs: me.initialization.fdbsMap.fdbs, //	分店标识
                        yhje: me.jiesuan.ysje - me.jiesuan.sshje, //	优惠金额
                        zdkoul: me.zdkoul, //整单折扣
                        //shkybh	varchar(20)	收款员编号	??
                        // rqtime	varchar(38)	结帐时间 	????
                        // bcbiaoshi	varchar(20)	班次标识	????
                        shl_count: "0.00" //	数量合计
                            // dy_lshh	varchar(22)	对应流水号	？？？？？？
                    }
                    me.service.insert(me, res, data => {
                        // resolve(data);
                    });

                    $(document).keydown(e => {
                        let key = e.keyCode;
                        // alert(key); 
                        let lis = $("#j_paymentMethod").find("li.on");
                        if (payStatus) {
                            if (key == 40) {
                                if (me.initialization.liIdx == 0) {
                                    $("#j_bill").blur();
                                }
                                lis.next("li").trigger("click");
                            }
                            if (key == 38) {
                                if (me.initialization.liIdx == 0) {
                                    $("#j_bill").blur();
                                }
                                lis.prev("li").trigger("click");
                            }
                        }
                    });
                } else {
                    alert("请先选择商品");
                }
            },
            saveTheInformation(e) { // 客户付完钱后保存收款信息
                let me = this;
                console.log(me.paymentMethods, 'ccccccccccccccccccc');
                payStatus = false;
                if (me.bill - me.jiesuan.sshje >= 100) {
                    return false;
                } else {
                    var pram = {
                        cardid: me.member.huiyuanid, //会员ID
                        lshh: me.initialization.liushui, //流水号
                        sktid: me.initialization.cashier.sktid, //收银编码
                        shkyid: me.initialization.cashier.shkyid, //收款员内码
                        fdbs: me.initialization.fdbsMap.fdbs, //分站标识
                        ysje: me.jiesuan.ysje, //应收金额
                        yhje: (me.jiesuan.ysje - me.jiesuan.sshje).toFixed(5), //优惠金额
                        sshje: me.jiesuan.sshje.toFixed(1), //实收金额
                        shkje: me.bill, //收款金额
                        zhaol: me.zhaol, //找零
                        moling: me.jiesuan.moling, //抹零
                        shky: me.initialization.cashier.shky, //收款员
                        plh: me.paymentMethods.plh, //排列号
                        jsfsid: me.paymentMethods.jsfsid, //结算方式内码
                        jsfsmch: me.paymentMethods.jsfsmch //结算方式名称
                    };
                    if (dingPay) {
                        dingPay = false;
                        me.service.pay(me, pram, data => {
                            if ((data.code = 200)) {
                                let res = {
                                    page: "1",
                                    rows: 5,
                                    sktid: me.initialization.cashier.sktid //收款台内码
                                }
                                me.service.selectMaLs(me, res, data => {
                                    me.onMoreLiushui();
                                    localStorage.setItem("code", data.code);
                                    me.onTurnover();
                                    me.onLodop();
                                    me.huiyuanbianji = false;
                                    me.huiyuanzengjia = true;
                                });

                                me.initialization.liIdx = 0;
                                payStatus = false;
                                let numFix = num => {
                                    return num < 10 ? +("0" + num) : num;
                                };
                                let html = ` `;
                                let date = new Date();
                                let year = date.getFullYear();
                                let month = date.getMonth() + 1;
                                let day = date.getDate();
                                let hours = date.getHours();
                                let minutes = date.getMinutes();
                                let seconds = date.getSeconds();
                                let time1 = `${year}-${numFix(month)}-${numFix(day)}`;
                                let time2 = `${numFix(hours)}:${numFix(minutes)}:${numFix(seconds)}`
                                me.printData.time1 = time1;
                                me.printData.time2 = time2;
                                me.printData.shky = me.initialization.cashier.shky;
                                me.printData.liushui = me.initialization.liushui;
                                me.printData.kkhname = me.member.theMemberInformation.kkhname;
                                me.printData.jifen = me.member.theMemberInformation.jifen;
                                me.printData.bill = parseFloat(me.bill).toFixed(2);
                                me.printData.sshje = me.jiesuan.sshje;
                                me.printData.zhaol = me.zhaol;
                                me.printData.moling = me.jiesuan.moling;
                                me.printData.jsfsmch = me.paymentMethods.jsfsmch;
                                me.printData.discount = Math.round((me.jiesuan.ysje - me.jiesuan.sshje) * 100) / 100;
                                me.printData.list = me.mainBody;
                                console.log(me.printData.list, "打印商品");
                                let htmls = "";
                                if (!me.printData.jifen) {
                                    me.printData.jifen = 0;
                                }
                                if (!me.printData.kkhname) {
                                    me.printData.kkhname = '无';
                                }
                                me.popBody = `<ul>
                                    <li class="clearfix lh2">
                                    <div class="pull-left b f16">应收金额:</div>
                                    <div class="pull-right">${me.jiesuan.ysje}</div>
                                    </li>
                                    <li class="clearfix lh2">
                                    <div class="pull-left b f16">收款金额:</div>
                                    <div class="pull-right">${me.printData.bill}</div>
                                    </li>
                                    <li class="clearfix lh2">
                                    <div class="pull-left b f16">优惠金额:</div>
                                    <div class="pull-right">${me.printData.discount}</div>
                                    </li>
                                    <li class="clearfix lh2">
                                    <div class="pull-left b f16">找零金额:</div>
                                    <div class="pull-right">${me.printData.zhaol}</div>
                                    </li>
                                    <li class="clearfix lh2">
                                    <div class="pull-left b f16">抹零金额:</div>
                                    <div class="pull-right">${me.printData.moling}</div>
                                    </li>
                                </ul>`;
                                $("#md_pops").find(".modal-body").append(me.popBody);
                                // localStorage.setItem('print', JSON.stringify(prints));
                                me.member.huiyuanid = "";
                                me.mainBody = [];
                                me.lastname = "";

                                for (let i in me.member.theMemberInformation) {
                                    Vue.delete(me.member.theMemberInformation, i);
                                }
                                for (let i in me.drugDetails.list) {
                                    Vue.delete(me.drugDetails.list, i);
                                }
                                me.service.selectFdbs(me, selectFdbs => {
                                    me.zdkoul = selectFdbs.data.allKouL;
                                });
                                $("#md_receivables").modal("hide");
                                setTimeout(function() {
                                    a_to_c = 1;
                                    sell_suc = 1;
                                    $("#md_pops").modal("show");
                                }, 0);
                            } else {
                                me.cancelThePayment();
                            }
                            dingPay = true;
                        });
                    }
                }

            },
            onSurname(e) { // 姓氏筛选
                let me = this;
                let fullname = me.member.theMemberInformation.kkhname;
                console.log(fullname);
                let hyphenated = me.biz.surname;
                let vLength = fullname.length;

                let lastname = "",
                    firstname = ""; //前为姓,后为名
                if (vLength > 2) {
                    let preTwoWords = fullname.substr(0, 2); //取命名的前两个字,看是否在复姓库中
                    if ($.inArray(preTwoWords, hyphenated) > -1) {
                        //表示存在
                        me.lastname = preTwoWords;
                        me.firstname = fullname.substr(2);
                    } else {
                        me.lastname = fullname.substr(0, 1);
                        me.firstname = fullname.substr(1);
                    }
                } else if (vLength == 2) {
                    //全名只有两个字时,以前一个为姓,后一下为名
                    me.lastname = fullname.substr(0, 1);
                    me.firstname = fullname.substr(1);
                } else {
                    me.lastname = fullname;
                }
                return [lastname, firstname];
            },
            onTurnover(e) { // 查询流水号接口
                let me = this;
                me.service.selectLsh(me, data => {
                    function PrefixInteger(num, length) {
                        return (Array(length).join("0") + num).slice(-length);
                    }
                    me.initialization.liushui = me.initialization.cashier.sktid + PrefixInteger(parseFloat(data.data), 9);
                })
            },
            onMoreLiushui(e) { //获取更多流水
                let me = this;
                let res = {
                    page: "1",
                    rows: 5,
                    sktid: me.initialization.cashier.sktid //收款台内码
                }
                me.service.selectMaLs(me, res, data => {
                    me.nissin = data.data.list;
                });
            },
            onSmallTicket(e) { //打印任意一张小票
                let me = this;
                me.$router.push({
                    path: '/smallTicket'
                })
            },
            onCancelTrading(e) { //删除现在有数据
                let me = this;
                me.service.deleteTheDeal(me, data => {
                    me.mainBody = [];
                    for (let i in me.drugDetails.list) {
                        me.$set(me.drugDetails.list, i, '');
                    }
                    me.member.theMemberInformation = {};
                    me.member.huiyuanid = '';
                    me.djMsg = '';
                    me.shlMsg = '';
                    me.koulMsg = '';
                    me.service.selectFdbs(me, data => {
                        me.zdkoul = data.data.allKouL;
                    })
                });
            },
            onLodop(e) { //打印
                let me = this;
                let LODOP;
                LODOP = getLodop();
                if (LODOP) {
                    let config = JSON.parse(localStorage.getItem("config"));
                    if (config) {
                        LODOP.SET_PRINT_PAGESIZE(3, 1385, 100, "");
                        if (localStorage.getItem('lodops') == '打印开启') {
                            if (config.format == '普通零售') {
                                LODOP.ADD_PRINT_HTM(0, 0, "100%", "100%", $("#lodopBxo1").html());
                                LODOP.ADD_PRINT_BARCODE($('#lodopBxo1').innerHeight(), 35, 120, 120, "QRCode", me.cfg.QRCode);
                            } else {
                                LODOP.ADD_PRINT_HTM(0, 0, "100%", "100%", $("#lodopBxo2").html());
                                LODOP.ADD_PRINT_BARCODE($('#lodopBxo2').innerHeight(), 35, 120, 120, "QRCode", me.cfg.QRCode);
                            }
                            LODOP.SET_PRINTER_INDEXA(config.drive);
                            LODOP.PRINT(); //PRINT,PREVIEW
                        } else {
                            LODOP.SEND_PRINT_RAWDATA(String.fromCharCode(27, 112, 1, 128, 128));
                        }
                    } else {
                        // layer.open({
                        //     content: "打印机未设置好",
                        //     btn: ["前往设置", "确认"],
                        //     yes: function(index, layero) {
                        //         me.$router.push({
                        //             path: "/System"
                        //         });
                        //         layer.cancel();
                        //     },
                        //     btn1: function(index, layero) {
                        //         layer.cancel();
                        //     }
                        // });
                    }
                } else {
                    let localLodop = localStorage.getItem("localLodop");
                    if (!localLodop) {
                        localLodop = localStorage.setItem("localLodop", "未安装打印驱动");
                        layer.alert('未安装打印驱动');
                    }
                    return;
                }
            },
            onCashbox(e) { //打开钱箱
                let me = this;
                let LODOP;
                LODOP = getLodop();
                if (LODOP) {
                    LODOP.SEND_PRINT_RAWDATA(String.fromCharCode(27, 112, 1, 128, 128));
                } else {
                    return;
                }
            },
            onLodops(e) { //是否打印小票
                let me = this;
                if (localStorage.getItem('lodops') == '未开启打印') {
                    localStorage.setItem('lodops', '打印开启');
                    // me.lodops = '打印开启';
                } else {
                    localStorage.setItem('lodops', '未开启打印');
                    // me.lodops = '未开启打印';
                }
                me.lodops = localStorage.getItem('lodops');
            },
            onNegativeInventory(e) { //是否允许自动提交
                let me = this;
                console.log(e.currentTarget);
                let {
                    state
                } = e.target.dataset;
                if (me.negativeInventory == "允许自动提交") {
                    me.negativeInventory = "不允许自动提交";
                    state = 0;
                } else {
                    me.negativeInventory = "允许自动提交";
                    state = 1;
                }

                let parameter = {
                    configName: "AUTOCOMMIT",
                    sktid: me.initialization.cashier.sktid,
                    fdbs: me.initialization.fdbsMap.fdbs,
                    value: state
                }
                me.service.updateSystemConfigByName(me, parameter, data => {
                    me.initialization.setConfig.tijiao.value = state;
                });
            },
            onScroll(e) { //商品表格滚动条在低部
                let me = this;
                $("#j_table_scroll").scrollTop($("#j_table_scroll")[0].scrollHeight);
            },
            check1(e) {
                let me = this;
                var a = /^(\d{4})-(\d{2})-(\d{2})$/
                if (!a.test($('.data').val())) {
                    layer.msg("日期格式不正确!");
                    return false
                }
            },
            check2(e) {
                let me = this;
                var a = /^(\d{4})-(\d{2})-(\d{2})$/
                if (!a.test($('.data').val())) {
                    layer.msg("日期格式不正确!");
                    return false
                }
            },
            Onsynchronization(e) { //同步库存
                let me = this;
                me.service.saveKuCunShulSync(me);
            },
            monitorNet() {
                let netStatus = $('.vpn');
                this.$http.get(this.cfg.api+"/ls/selectIpPing").then(res=> {
                    res.body.data == 1 ? netStatus.addClass('vpn-online').removeClass('vpn-offline') : netStatus.addClass('vpn-offline').removeClass('vpn-online');
                }, res=> {
                    netStatus.addClass('vpn-offline').removeClass('vpn-online');
                });
            }
        },
        mounted() {
            this.monitorNet();
            setInterval(this.monitorNet, 10000);
            let me = this;
            $("#optionsRadios").attr("checked", true);
            let user = JSON.parse(sessionStorage.getItem("user"));
            if (!user) {
                router.push({
                    path: "/login"
                })
                return;
            } else {
                me.initialization.cashier.shky = user.shky;
                me.initialization.cashier.shkyid = user.shkyid;
            }
            me.initialization.cashier.sktid = localStorage.getItem("sktId");

            var time = new Date();
            me.today = time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate(); //发卡日期
            $(".data").val(me.today);
            $(".form_date").datetimepicker({
                language: "zh-CN",
                weekStart: 1,
                todayBtn: 1,
                autoclose: 1,
                todayHighlight: 1,
                startView: 2,
                minView: 2,
                forceParse: 0
            });
            me.sktId = localStorage.getItem("sktId");
            me.today = time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate(); //发卡日期
            me.closingDate = time.getFullYear() + 3 + "-" + (time.getMonth() + 1) + "-" + time.getDate(); //发卡截止日期
            let res = {
                pageName: 'MXLS_SHOW',
                sktid: me.initialization.cashier.sktid
            }
            me.service.indexLsNew(me, res, data => { //初始化所有数据信息
                me.initialization.fdbsMap = data.data.fdbsMap;
                me.initialization.department = data.data.bmDoc;
                me.initialization.huowei = data.data.hwList;
                me.initialization.theSalesman = data.data.xsyList;
                me.member.theMemberInformation = data.data.huiYuanInfo;

                localStorage.setItem("fdbs", me.initialization.fdbsMap.fdbs);
                me.zdkoul = me.initialization.fdbsMap.allKouL;
                if (data.data.sPMxlsList.length > 0) {
                    me.mainBody = data.data.sPMxlsList;
                    me.cancelThePayment();
                    me.onScroll();
                    setTimeout(function() {
                        let o = $("#j_drugList").find(".on");
                        o.trigger("click");
                    }, 0);
                } else {
                    $("#j_searchDrug").focus();
                }
                if (me.initialization.fdbsMap.adminid == user.shkyid) {
                    me.initialization.adminid = false;
                } else {
                    me.initialization.adminid = true;
                }
                data.data.configList.forEach((item, index) => {
                    if (item.name == "NEGATIVE_INVENTORY") {
                        me.initialization.setConfig.kucun = item;
                    }
                    if (item.name == "RETURNED_GOODS") {
                        me.initialization.setConfig.tuihuo = item;
                    }
                    if (item.name == "AUTOCOMMIT") {
                        me.initialization.setConfig.tijiao = item;
                    }
                    if (item.name == "LOWEST_KOULV") {
                        me.initialization.setConfig.koulv = item;
                    }
                });
                if (me.initialization.setConfig.tijiao.value == 0) {
                    $('#j_negativeInventory').attr('data-state', 0);
                    me.negativeInventory = '不允许自动提交';
                } else {
                    $('#j_negativeInventory').attr('data-state', 1);
                    me.negativeInventory = '允许自动提交';
                }
                if (me.member.theMemberInformation) {
                    me.zdkoul = data.data.huiYuanInfo.koulv;
                    me.member.huiyuanid = data.data.huiYuanInfo.cardid;
                    me.onSurname();
                }
            });
            //获取页面主体表格th
            me.service.selectGeneralShowZiDuan(me);

            //日清交易流水接口
            let lsRes = {
                page: "1",
                rows: "5",
                sktid: me.initialization.cashier.sktid //收款台内码
            }
            me.service.selectMaLs(me, lsRes, data => {
                me.nissin = data.data.list;
                if (!data.data.count) {
                    me.initialization.lsNum == 1;
                } else {
                    me.initialization.lsNum = data.data.count;
                }
            });

            //初始化查询流水号接口
            me.onTurnover();

            //delete键删除数据
            $(document).keydown(e => {
                let key = e.keyCode;
                if (key == 46) {
                    var o = $("#j_drugList");
                    let plh = o.find(".on").attr("data-plh");
                    if (o.find(".on").length > 0) {
                        let deletePromise = new Promise((resolve, reject) => {
                            let res = {
                                fdbs: me.initialization.fdbsMap.fdbs,
                                lshh: me.initialization.liushui,
                                sktid: me.initialization.cashier.sktid,
                                plh: plh
                            }
                            me.service.deleteTmpPosMxls(me, res, data => {
                                resolve(data);
                            });
                        }).then((resolve, reject) => {
                            if (resolve.code == 200) {
                                let idx;
                                me.mainBody.forEach((item, index) => {
                                    if (item.plh == plh) {
                                        idx = index;
                                    }
                                });
                                Vue.delete(me.mainBody, idx);
                                setItemMethod("mainBody", me.mainBody);
                            }
                        }).then(() => {
                            o.find("tr:last").trigger("click");
                            setTimeout(function() {
                                if (me.mainBody.length <= 0) {
                                    me.djMsg = '';
                                    me.shlMsg = '';
                                    me.koulMsg = '';
                                    me.drugDetails.list = {};
                                    $('#j_searchDrug').focus();
                                }
                            }, 0);
                        });
                    }
                }
            });

            $("#j_searchDrug").focus(function() {
                who = "搜索";
                bfocus = true;
                bblur = false;
                execTime = 1;
            });

            $("#j_searchDrug").blur(function() {
                who = "搜索";
                bfocus = false;
                bblur = true;
            });

            $("#j_bill").focus(function() {
                who = "收款金额";
                bfocus = true;
                bblur = false;
            });
            $("#j_bill").blur(function() {
                who = "收款金额";
                bfocus = false;
                bblur = true;
            });

            $("input").focus(event => {
                event.currentTarget.select();
            });

            $("#md_pops").on("hide.bs.modal", function() {
                setTimeout(function() {
                    $("#j_searchDrug").focus();
                }, 0);
            });

            $(document).keydown(function(e) { //页面键盘事件
                var key = e.keyCode;
                // alert(key);
                let trs = $("#j_drugList").find("tr.on");
                if (sell_suc == 1) {
                    $("#md_pops").modal("hide");
                    $("#md_pops").find(".modal-body").find("ul").remove();

                    sell_suc = 0;
                    // history.go(0);
                    return;
                }
                if (key == 113) {
                    //F2 切换搜索
                    if (me.searchText == "搜索商品(F2)") {
                        me.searchText = "搜索会员(F2)";
                        setTimeout(function() {
                            $("#j_searchMember").focus();
                        }, 0);
                    } else {
                        me.searchText = "搜索商品(F2)";
                        setTimeout(function() {
                            $("#j_searchDrug").focus();
                        });
                    }
                    event.returnValue = false;
                }
                if (key == 116) {
                    //F5 禁刷新
                    // event.returnValue = false;
                }

                if (key == 117) {
                    //F6 取消交易
                    me.onCancelTrading();
                    $("#j_searchDrug").focus();
                    event.returnValue = false;
                }

                if (key == 119) {
                    //F8打开钱箱
                    me.onCashbox();
                    event.returnValue = false;
                }
                if (key == 123) {
                    //F12收款
                    me.onReceivables();
                    event.returnValue = false;
                }
                if (e.altKey && key == 89) {
                    //销售员 alt+y
                    $("#k_alt_y").focus();
                    event.returnValue = false;
                }
                if (e.altKey && key == 75) {
                    //整单折扣率 alt+k
                    $("#k_alt_k").focus();
                    event.returnValue = false;
                }
                if (e.altKey && key == 77) {
                    //部门 alt+m
                    $("#k_alt_m").focus();
                    event.returnValue = false;
                }
                if (e.altKey && key == 83) {
                    //数量 alt+s
                    $("#k_alt_s").focus();
                    event.returnValue = false;
                }
                if (e.altKey && key == 68) {
                    //单价 alt+d //目前与IE谷歌快捷键冲突
                    $("#k_alt_d").focus();
                    event.returnValue = false;
                }
                if (e.altKey && key == 67) {
                    //折扣率 alt+c
                    $("#k_alt_c").focus();
                    event.returnValue = false;
                }
                if (e.altKey && key == 66) {
                    //搜索商品(F2) alt+b
                    if (me.searchText == "搜索会员(F2)") {
                        me.onSwitch();
                    }
                    setTimeout(() => {
                        $("#j_searchDrug").focus();
                    }, 0);
                }
                if (e.altKey && key == 88) {
                    //搜索会员(F2) alt+x
                    if (me.searchText == "搜索商品(F2)") {
                        me.onSwitch();
                        setTimeout(() => {
                            $("#j_searchMember").focus();
                        }, 0);
                    }
                }

                if (key == 40) {
                    if (($(":focus").attr("id") == "k_alt_s") && $(':focus').attr('id') != 'j_searchDrug') {
                        trs.next("tr").trigger("click");
                        // $('#k_alt_s').focus();
                        event.returnValue = false;
                    }
                    if ($(":focus").attr("id") == "k_alt_d" && $(':focus').attr('id') != 'j_searchDrug') {
                        trs.next("tr").trigger("click");
                        $('#k_alt_d').focus();
                        event.returnValue = false;
                    }
                    if ($(":focus").attr("id") == "k_alt_c" && $(':focus').attr('id') != 'j_searchDrug') {
                        trs.next("tr").trigger("click");
                        // $('#k_alt_c').focus();
                        event.returnValue = false;
                    }
                }

                if (key == 38) {
                    if (($(":focus").attr("id") == "k_alt_s") && $(':focus').attr('id') != 'j_searchDrug') {
                        trs.prev("tr").trigger("click");
                        // $('#k_alt_s').focus();
                        event.returnValue = false;
                    }
                    if ($(":focus").attr("id") == "k_alt_d" && $(':focus').attr('id') != 'j_searchDrug') {
                        trs.prev("tr").trigger("click");
                        // $('#k_alt_d').focus();
                        event.returnValue = false;
                    }
                    if ($(":focus").attr("id") == "k_alt_c" && $(':focus').attr('id') != 'j_searchDrug') {
                        trs.prev("tr").trigger("click");
                        // $('#k_alt_c').focus();
                        event.returnValue = false;
                    }
                }
                if (key == 9) {
                    if ($(":focus").attr("id") == "j_receivables") {
                        $("#j_searchDrug").focus();
                        event.returnValue = false;
                    }
                }
                if (key == 13) {
                    if (who == "修改数量" && bfocus == true) {
                        a_to_c = 1;
                        console.log(bfocus, execTime, a_to_c, who, bblur, '修改数量');
                        me.onQuantityBlur();
                    }
                    if (who == "单价" && bfocus == true) {
                        a_to_c = 1;
                        me.onPriceBlur();
                    }

                    if (who == "折扣率" && bfocus == true) {
                        a_to_c = 1;
                        me.onDiscountBlur();
                    }
                    if (who == "搜索" && bfocus == true) {
                        console.log(bfocus, execTime, a_to_c, who, bblur, '搜索');
                        if (a_to_c == 0) {
                            if (execTime == 1) {
                                if ($("#j_searchDrug").val() == "") {
                                    me.onReceivables();
                                }
                                execTime = 0;
                            }
                        } else {
                            a_to_c = 0;
                        }
                    }
                    if ($("#md_receivables").hasClass("in")) {
                        $("#md_receivables").modal("show");
                        // $('#j_saveTheInformation').trigger('click');
                        me.saveTheInformation();
                    }
                    if (who == "收款金额" && bfocus == true) {
                        s_to_z = 1;
                        // $("#j_zhaol").focus();
                        $("#md_receivables").modal("show");
                        // $('#j_saveTheInformation').trigger('click');
                        me.saveTheInformation();
                    }
                    if (who == "找零" && bfocus == true) {
                        if (s_to_z == 0) {
                            if (execTime == 1) {
                                $("#md_receivables").modal("show");
                                // $('#j_saveTheInformation').trigger('click');
                                me.saveTheInformation();
                            }
                            execTime = 0;
                        } else {
                            s_to_z = 0;
                        }
                    }
                }
            });

            $(document).on('keydown click', function(e) {
                clearInterval(intervalId);
            });

            var intervalId = setInterval(function() {
                $('#j_searchDrug').focus();
            }, 30000);

            if (localStorage.getItem('lodops')) {
                let lodops = localStorage.getItem('lodops');
                localStorage.setItem('lodops', lodops)
            } else {
                localStorage.setItem('lodops', '打印开启')
            }
            me.lodops = localStorage.getItem('lodops');
            $("#j_searchDrug").autocomplete();
            me.onSearchMember();

            function mainH() {
                let winHeight = $(window).innerHeight();
                let rColumn = $('.r-column').innerHeight();
                let nav = $('.navbar').innerHeight();
                let hMsg = $('.h-msg').innerHeight();
                let bMain = $('.b-main').innerHeight();
                let tableHead = $('.table-head').innerHeight();
                let fdMsg = $('.fd-msg').innerHeight();

                $('#j_table_scroll').css('height', winHeight - nav - hMsg - bMain - tableHead - fdMsg - 60);
                // if (winHeight >= rColumn) {
                // } else {
                //     $('#j_table_scroll').css('height', 808 - hMsg - bMain - tableHead - fdMsg - 60)
                // }
            }
            $(window).resize(function() {
                mainH();
            });
            mainH();
        },
        beforeDestroy() {
            let me = this;
            history.go(0);
        }
    };
</script>